package com.cat.springbootannocation.controller;

import java.util.List;

import com.cat.springbootannocation.entity.Product;
import com.cat.springbootannocation.mapper.ProductMapper;
import com.cat.springbootannocation.service.IProductService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zss
 * @since 2020-09-16
 */
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService productService;
    @Autowired
    private ProductMapper productMapper;


    @RequestMapping("/saveProduct")
    public void saveProduct(String product_name,String lot,String address){
        Product product = new Product();
        product.setAddress(address);
        product.setLot(lot);
        product.setProductName(product_name);
        productService.save(product);
        productMapper.insert(product);
        // List<Product> list =  productService.getAllProduct();
        // for(Product p :  list){
        //     System.out.println(p);
        // }
        productService.updateProducts();
    }

}
